#! /bin/sh
#
# psize.sh -- determine this system's pipe size, and write a define to
#             pipesize.h so ulimit.c can use it.

TMPFILE="`mktemp -t pipsize.XXXXXXXXXX`" || exit 1

trap 'rm -f -- "$TMPFILE"; exit 1' 1 2 3 6 15
trap 'rm -f -- "$TMPFILE"' 0

echo "/*"
echo " * pipesize.h"
echo " *"
echo " * This file is automatically generated by psize.sh"
echo " * Do not edit!"
echo " */"
echo ""

./psize.aux 2>"$TMPFILE" | sleep 3

if [ -s "$TMPFILE" ]; then
	echo "#define PIPESIZE `cat "$TMPFILE"`"
else
	echo "#define PIPESIZE 512"
fi

exit 0
